import utime
import network
###
def connect_wifi(wifi_sid,wifi_pw):

        wlan = network.WLAN(network.STA_IF)
        wlan.active(True)
        count = 0
        if not wlan.isconnected():
            print('connecting to network...')
            wlan.connect(wifi_sid, wifi_pw)
            while (not wlan.isconnected()) and count < 10:
                utime.sleep(1)
                count = count+1
        print('network config:', wlan.ifconfig())
        return wlan
def disconnect_wifi(wlan):
    if wlan is not None:
        wlan.disconnect()
        wlan.active(False)